package com.hxl.tech.gateway.auth.dao;


import com.hxl.tech.gateway.auth.model.ApplicationOauth;
import com.hxl.tech.gateway.auth.model.QApplicationOauth;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class ApplicationOAtuhDao {

    @Resource
    private JPAQueryFactory jpaQueryFactory;

    private QApplicationOauth qApplicationOauth = QApplicationOauth.applicationOauth;

    public List<ApplicationOauth> findByAppId(String appId) {
        JPAQuery<ApplicationOauth> query = jpaQueryFactory.select(qApplicationOauth)
                .from(qApplicationOauth)
                .where(qApplicationOauth.id.appId.eq(appId));

        return query.fetch();
    }

}
